//
//  VerticalButton.m
//  糗事百科
//
//  Created by 奚超明 on 16/5/28.
//  Copyright © 2016年 奚超明. All rights reserved.
//

#import "VerticalButton.h"

@implementation VerticalButton

#pragma mark - Xib创建
- (void)awakeFromNib
{
    [self setupLabel];
}

#pragma mark - 代码创建
- (instancetype)initWithFrame:(CGRect)frame
{
    if (self == [super initWithFrame:frame]) {
        [self setupLabel];
    }
    return self;
}

#pragma mark - 设置文字居中排布
- (void)setupLabel
{
    self.titleLabel.textAlignment = NSTextAlignmentCenter;
}

#pragma mark - 文字及图片竖直排布
- (void)layoutSubviews
{
    [super layoutSubviews];
    
    // 设置图片
    self.imageView.xcm_width = self.xcm_width - 30;
    self.imageView.xcm_height = self.imageView.xcm_width;
    self.imageView.xcm_x = 15;
    self.imageView.xcm_y = 0;
    
    // 设置文字
    self.titleLabel.xcm_width = self.xcm_width;
    self.titleLabel.xcm_height = self.xcm_height - self.imageView.xcm_height;
    self.titleLabel.xcm_x = 0;
    self.titleLabel.xcm_y = self.imageView.xcm_height;
}
@end
